package com.hj.javase;

/**
 * @Author : hujing
 * @Date: 2025/7/30 14:21
 * @Description: 枚举类
 */
public enum Color {
    RED("红色",255, 0, 0),
    GREEN("绿色", 0, 255, 0),
    BLUE("蓝色", 0, 0, 255);
    
    // 成员变量
    private final String name;
    private final int red;
    private final int green;
    private final int blue;
    
    private Color(String name,int red,int green,int blue){
        this.name = name;
        this.red = red;
        this.green = green;
        this.blue = blue;
    }

    // 提供公共方法获取成员变量的值
    public String getName() {
        return name;
    }

    public int getRed() {
        return red;
    }

    public int getGreen() {
        return green;
    }

    public int getBlue() {
        return blue;
    }

    // 可以重写toString方法
    @Override
    public String toString() {
        return name + " (RGB: " + red + ", " + green + ", " + blue + ")";
    }

    // 测试枚举类
    public static void main(String[] args) {
        for (Color color : Color.values()) {
            System.out.println(color);
        }
        
        System.out.println(Color.BLUE.getName());

        Color red1 = Color.RED;
        if ("黑色".equals(red1.getName())){
            System.out.println("红色");
        }
    }
}
